/**
 * 个人页面及管理系统样式文件
 * 采用模块化设计，优化性能和可维护性
 */

/* ===============================================
   全局变量与基础样式
   =============================================== */
:root {
  /* 颜色变量 */
  --primary: #3B82F6;    /* 主色调 - 蓝色 */
  --secondary: #10B981;  /* 辅助色 - 绿色 */
  --accent: #8B5CF6;     /* 强调色 - 紫色 */
  --dark: #1F2937;       /* 深色文本 */
  --light: #F9FAFB;      /* 浅色背景 */
  --gray: #6B7280;       /* 灰色文本 */
  --white: #FFFFFF;      /* 白色 */
  
  /* 阴影变量 */
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* 过渡效果 */
  --transition: all 0.3s ease;
}

/* 基础重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* 基础样式 */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--dark);
  background-color: var(--light);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===============================================
   导航栏样式
   =============================================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.95);
  z-index: 100;
  padding: 15px 0;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
}

.navbar-logo {
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.navbar-logo:hover {
  transform: scale(1.05);
}

.logo-icon {
  font-size: 1.2rem;
  font-weight: 700;
}

.navbar-links {
  display: none;
}

.nav-link {
  text-decoration: none;
  color: var(--gray);
  margin: 0 1rem;
  padding: 0.5rem 0;
  transition: var(--transition);
  font-weight: 500;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--primary);
  outline: none;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

.menu-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray);
  transition: var(--transition);
  padding: 0.5rem;
  border-radius: 4px;
}

.menu-button:hover,
.menu-button:focus {
  color: var(--primary);
  background-color: rgba(59, 130, 246, 0.1);
  outline: none;
}

.mobile-menu {
  display: none;
  padding: 1rem;
  flex-direction: column;
  gap: 1rem;
  background-color: var(--white);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.mobile-nav-link {
  text-decoration: none;
  color: var(--gray);
  padding: 0.75rem 1rem;
  transition: var(--transition);
  border-radius: 4px;
  font-weight: 500;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
  color: var(--primary);
  background-color: rgba(59, 130, 246, 0.1);
  outline: none;
}

/* ===============================================
   头部区域样式
   =============================================== */
.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 0;
  background: linear-gradient(135deg, #EFF6FF 0%, #EEF2FF 100%);
  position: relative;
  overflow: hidden;
}

/* 头像样式 */
.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 20px;
  border: 4px solid var(--white);
  box-shadow: var(--shadow);
}

/* 个人信息样式 */
.name {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--dark);
}

.profession {
  font-size: 1.2rem;
  color: var(--gray);
  margin-bottom: 1.5rem;
}

.motto {
  font-style: italic;
  font-size: 1.1rem;
  color: var(--gray);
  max-width: 800px;
  margin: 0 auto 2rem;
  padding: 1rem;
  border-left: 4px solid var(--primary);
  background-color: rgba(255, 255, 255, 0.8);
}

/* 社交链接样式 */
.social-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.social-link {
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  font-weight: 500;
  transition: var(--transition);
  background-color: #f3f4f6;
  color: var(--gray);
}

.social-link:hover {
  background-color: var(--primary);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* ===============================================
   通用部分样式
   =============================================== */
.section {
  padding: 3rem 1rem;
  animation: fadeIn 0.5s ease-in-out;
}

.section-title {
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 2rem;
  color: var(--dark);
  position: relative;
}

.section-title::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background-color: var(--primary);
  margin: 0.5rem auto 0;
  border-radius: 3px;
}

/* ===============================================
   关于我部分样式
   =============================================== */
.about-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  background-color: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.about-text {
  margin-bottom: 1rem;
  line-height: 1.7;
  color: var(--gray);
}

.about-text:last-child {
  margin-bottom: 0;
}

/* ===============================================
   项目部分样式
   =============================================== */
.projects-section {
  background-color: var(--light);
}

.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.project-card {
  background-color: var(--white);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  transform: translateZ(0);
  backface-visibility: hidden;
}

.project-card:hover {
  transform: translateY(-5px) translateZ(0);
  box-shadow: var(--shadow-hover);
}

.project-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.project-card:hover .project-image {
  transform: scale(1.05);
}

.project-info {
  padding: 1.5rem;
}

.project-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--dark);
}

.project-description {
  margin-bottom: 1rem;
  color: var(--gray);
  line-height: 1.6;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag {
  padding: 0.25rem 0.75rem;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* 项目标签颜色 */
.tag-react { background-color: #EFF6FF; color: #2563EB; }
.tag-node { background-color: #ECFDF5; color: #10B981; }
.tag-vue { background-color: #ECFDF5; color: #10B981; }
.tag-django { background-color: #F3E8FF; color: #8B5CF6; }
.tag-echarts { background-color: #FFF7ED; color: #EA580C; }

.project-link {
  display: inline-block;
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.project-link:hover {
  text-decoration: underline;
}

/* ===============================================
   联系部分样式
   =============================================== */
.contact-info {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
  background-color: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.contact-item:last-child {
  margin-bottom: 0;
}

.contact-icon {
  font-size: 1.5rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: #f3f4f6;
  color: var(--primary);
}

.contact-details h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--dark);
}

.contact-value {
  color: var(--gray);
}

/* ===============================================
   页脚样式
   =============================================== */
footer {
  background-color: var(--dark);
  color: var(--white);
  padding: 2rem 1rem;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 1200px;
  margin: 0 auto;
}

.copyright {
  margin-bottom: 1rem;
  color: #9CA3AF;
}

.footer-social {
  display: flex;
  gap: 1rem;
}

.footer-social-link {
  color: #9CA3AF;
  text-decoration: none;
  transition: var(--transition);
  font-size: 1.1rem;
}

.footer-social-link:hover {
  color: var(--white);
  transform: translateY(-2px);
}

/* ===============================================
   响应式设计
   =============================================== */

/* 平板设备 */
@media (min-width: 768px) {
  /* 导航栏 */
  .navbar-links {
    display: flex;
  }
  
  .menu-button {
    display: none;
  }
  
  .mobile-menu {
    display: none !important;
  }
  
  /* 项目网格 */
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* 字体大小 */
  .name {
    font-size: 3rem;
  }
}

/* 桌面设备 */
@media (min-width: 1024px) {
  /* 项目网格 */
  .projects-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* 头部区域 */
  .header-content {
    padding: 3rem 1rem;
  }
}

/* ===============================================
   性能优化样式
   =============================================== */

/* 图片优化 */
.project-image,
.avatar {
  image-rendering: optimizeSpeed;
  image-rendering: -moz-crisp-edges;
  image-rendering: -o-crisp-edges;
  image-rendering: crisp-edges;
}

/* 动画定义 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* 容器样式 */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 减少重排重绘的CSS */
body {
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: auto;
}

/* ===============================================
   通用表单样式 (用于登录页和管理页)
   =============================================== */
.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #E5E7EB;
  border-radius: 4px;
  font-size: 1rem;
  transition: var(--transition);
  background-color: var(--light);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control.error {
  border-color: #EF4444;
}

/* 通用按钮样式 */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
  text-align: center;
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background-color: #2563EB;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--white);
}

.btn-secondary:hover {
  background-color: #059669;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-danger {
  background-color: #EF4444;
  color: var(--white);
}

.btn-danger:hover {
  background-color: #DC2626;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background-color: var(--primary);
  color: var(--white);
}

/* 通用卡片样式 */
.card {
  background-color: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.card-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #E5E7EB;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.card-body {
  padding: 1rem 0;
}

.card-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #E5E7EB;
}

/* ===============================================
   通用表格样式 (用于管理页)
   =============================================== */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #E5E7EB;
}

.table th {
  background-color: #F9FAFB;
  font-weight: 600;
  color: var(--dark);
}

.table tr:hover {
  background-color: #F9FAFB;
}

.table.striped tr:nth-child(even) {
  background-color: #F9FAFB;
}

/* ===============================================
   通用工具类
   =============================================== */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.text-primary {
  color: var(--primary);
}

.text-secondary {
  color: var(--secondary);
}

.text-danger {
  color: #EF4444;
}

.text-success {
  color: var(--secondary);
}

.text-warning {
  color: #F59E0B;
}

.text-muted {
  color: var(--gray);
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 2rem; }

/* ===============================================
   响应式工具类
   =============================================== */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  
  .text-center-mobile {
    text-align: center;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }
}

/* ===============================================
   加载状态样式
   =============================================== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(59, 130, 246, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===============================================
   动画效果
   =============================================== */
.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-in {
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}